/**
 * Created by gongxun on 17/8/2.
 */

var HttpCodes = function(){
    var that = {};

    that.getCodes = function(){

    };


    //随机标志
    that.randomBiaojiCode = function(){
        var keys = [
            "1",
            "2",
            "3",
            "4",
            "5",
            "6",
            "7",
            "8",
            "9",
            "0",
            "q",
            "w",
            "e",
            "r",
            "t",
            "y",
            "u",
            "i",
            "o",
            "p",
            "a",
            "s",
            "d",
            "f",
            "g",
            "h",
            "j",
            "k",
            "l",
            "z",
            "x",
            "c",
            "v",
            "b",
            "n",
            "m"
        ];
        // var keys = [
        //     "娭",
        //     "瘢",
        //     "鸨",
        //     "鞴",
        //     "荸",
        //     "箅",
        //     "皕",
        //     "赑",
        //     "藊",
        //     "弁",
        //     "镳",
        //     "醭",
        //     "倘",
        //     "绰",
        //     "蒇",
        //     "碜",
        //     "眵",
        //     "踟",
        //     "啻",
        //     "瘛",
        //     "铳",
        //     "匙",
        //     "欻",
        //     "搋",
        //     "膪",
        //     "槌",
        //     "爨",
        //     "皴"
        // ];

        var len = keys.length;

        var mapkey = {};

        for (var i = 0; i < 50; i++){
            var tests = [];
            for (var j = 0; j < 7; j++){
                var testKey = "";
                while (testKey == "" || mapkey[testKey] != undefined){
                    testKey = "";
                    for (var x = 0; x < 5; x++){
                        var randomKey = keys[parseInt(Math.random() * len)];
                        testKey += randomKey;
                    }
                }
                mapkey[testKey] = 1;
                tests.push(testKey);
            }

            var logStr = "{";
            for (var j = 0; j < tests.length; j++){
                logStr += ("\"" + tests[j] + "\",");
            }
            logStr += "}";
            cc.log(logStr);
        }
    };


    that.getNewCodeForWeihu = function(code){
        var codess = [["apggecblqg","xdqrsatfye","wgodueqktu","bmwcypntlv","sljnfhqtmr","gphwtzuact","inuvxvhzho","ngosqryswz","guzsrtfdpp","tltewgassr","egtaknbylp","wcyqlzgnyp","rxencjkmhd","erpzgfsoxb","pytbnyniyg","ommolwzhkd","krpehyhwkj","makchrhwjh","zznulsbxck","zqavzjcmfk","pmmisettaw","ztsmviilpf","ezqktoflhp","vguvexgiru","xpxbgobwei","qgpeapdmkl","uhetpmsrkj","tfprmmnmub","wbdxrpuqao","scwnjqqewl"],
            ["jebmuunntv","mvdfcjewdz","kulnznixeq","ppsaunhapv","farihwjnpi","hpzfrigcgh","pplsodskui","cmfbkmngaj","akutizvcqa","fjavfftmqi","mnughjmigo","nrvfbnjdsh","dncwodyzwq","wxjjuxwkfg","gdyymozoma","zosfvnyfba","uobxjxbuyz","jmwvsuqsnt","urffjashde","lfrgbjceza","vylutnpsqb","walmbfcqsa","hhmbvchbft","nibjhyaylf","zcvrfmyboz","conbaslgcb","lyczpptvif","wjmlqlkayi","ainypuudwd","flkvhhguap"],
            ["wtbpqtgswy","pttwqqtvuk","gwaohhaipw","ubqlbesbii","qbswlrbsis","abdmebcwpg","ijtngidxwx","ucnzsmtwtl","buygymfgnn","okbhvfwtgg","tamhwmfyfu","yzvwmbpmor","dzugdtmyak","grecfjxhkw","opnswxkwki","vdfyhdrsuc","abxmbiqtnb","nwltstywjx","suezckykhk","evnpwbpjtz","fbjhxgmxlq","bxoqwrrcmk","ucmxfourij","dohfyithoj","mjgrvkdjgk","foehhxofft","nxuqarlrla","yzvrsymgpo","fxtfsfkxqs","goceelzhoj"],
            ["zsrjofmdqj","pkzxynpykg","patojolext","urrmowfdsz","klvtabawzy","uijrmwkhhq","lmnhemqmxx","avfqzobijg","gketfjfxwv","jbegufccwr","asyegnqxoc","cxqhostegg","lbrkikeekq","goeargroej","xmdhgyfkko","jkukxdvgfg","orvhqkswbs","nrsicpjgln","stxhufhaxe","awftmnttzx","gqcfipjpnp","qvtpkucmmf","psupzbnmgo","xebsmojuau","zycamscwyc","uqcwfticzi","eciisfzhak","ubzmomjiuv","ceaqxfdfkm","wphurelebj"],
            ["yqzpvintyp","ehjfbmirdd","wavkvacmop","ivwroafhay","blxsfseqnp","yntajqicrm","enfnmffzme","xwrnpiqssq","ylumofiqau","bjpgrurqwe","eocdnantsc","pyibeujsye","whdikcbaei","orukxzsbfp","nbtvlrwdxr","apsyxgfaso","unyzgieexo","eyyktgxlzj","jlwtjwpmht","nuvlmlyehz","ycxzwximcv","lmakohplqt","rnowzbgayd","quomjtfbgw","vmtdbsitbn","qndrjyctwc","pfdcvpexqx","yqgltgryor","iejxwmpigf","ampypmppaw"],
            ["nabyucqntk","fkxpczazha","hipsophliu","hnidwhgvcn","wjpglhbtgi","xswwzqpenf","spyjvmjnvp","ilurwvywmu","lmpcknwmha","jbakqoyawm","itnewlpyjj","oyeleoyxby","otiekjwpdh","pqcnsfjzdm","npvoqenrsa","ovfemwptwd","xfxjxtrqvs","hmavphooig","rmxriyxjcm","lzggpxotmn","lhnrgfopqj","qyrlzurfin","twxmhnbmfa","jivwtxgakd","qlpaywpbvx","suedmuffeb","atcmdwkvpx","ytsjfchjfk","yzcxnptqzd","twsscztrfs"],
            ["xbhwcbxpqb","qbpsbwestv","tcabwxhxdq","izyhhpnxmp","ycrjqccyft","iuzhrwzwgy","onfencdpaz","xctcrtdzrc","jcfllhevqh","uycetuflfy","whvpqefoym","wzsfcyddfe","nsjqpsuwjf","txtmzlrvrs","akldzihzhx","ueltufnjqt","moqtedyois","jimvqdnvgt","mdsvhorxjs","rodpavtozy","ibidkfumho","kasgzzwrye","fwtsxoclbq","kylavmhhfx","xwjzsqmtit","bqlbsabwex","ykviczbbbo","ckiorpqtfg","hfqmgxmlya","fzwwiyemug"],
            ["jmmctfqaev","fzhtvxpbzz","cdqtaafdfp","lxqkopcqnn","mpqatjfkeh","umxersavja","scedlhndzp","naryucnkgp","anyjnickfy","efleaacyng","eobwqpjqnf","zjrzjpbygv","pooixjorse","ilukiehvax","sravhmehog","chsjrnojnj","rhfpjlijgy","rhuvawkwrj","elxgdwfhqw","zfitbazfmm","ufcbbitmhl","rossrkdbcl","ginmkjbrhy","qakkmghuyf","dqinjnaigd","wxbvlbfvcm","iipngliczp","sfxjbttbuh","visenuynzj","gmzkifrgvw"],
            ["sspgrtvddn","rhfytnqiia","ykvmnjlogw","vpzovtiyol","duixrykwyf","mxfiljtnxi","ynnzuunolw","mqssnjuqlr","smxvnkvbjl","fylfdurcxw","cemldbhbfo","rntyfrhwbv","pvejhrsdun","iamalxzmzg","fmginotuvk","yhtsnonprd","sssgfudaov","njizhakkix","wuapwjobpn","claipowpsv","rikdbcezls","asdderbfuj","pdguonazqq","mfrzeiaykl","dkhrsrhutx","igzvddocpt","djyrzesvxc","hnudccznrp","mltnasughi","rytsjhzmrf"],
            ["ftbhtdcwdr","oxhdqlyevc","uzxpnhujml","cpetjeskxe","zwhkbxohdz","izwbijrixb","cxvcvesbqr","nprqoqifwv","ynwjlstoda","yadcwoiqac","ugkzxoxdkb","lrwvaioxms","eyfnkjoprp","yymszhsnlf","mkeftjtexi","immolevcyj","ikiczelltz","lmhlnnffji","ngfhpwwttt","qhszfdfohk","fzpxuzevax","ldkwjhfzkj","nbjtpxwdeb","eutqtvtszb","ekfatbdqwx","ykgssctupl","gcdaoetupk","npqsnvxmcu","npcbuipkqa","fguusinkoc"]];

        var apples = [
            "http://api.qixinxx.com",
            "http://47.95.32.128",      //备
            "http://47.94.47.91",       //ti
            "http://47.94.43.220",      //ti
            "http://47.94.43.216"       //ti
        ];

        cc.log("size1:" + codess.length);
        cc.log("size2:" + apples.length);

        for (var i = 0; i < apples.length; i++){
            var codes = codess[i];
            var index = mo.gameHelper.findValueForArray(codes, code);
            if (index != null){
                return apples[i];
            }
        }
        return "";
    };


    //获取时间
    that.getCodeForTime = function(code){
        var codess =[
            ["tveafhmvjc","jixajxzqvz","esonsltqid","kqyzmpehkw","vlzzgwfyjo","pylwavzxzs","vsctmwuplr","whihszeknr","bmfvuqmaui","rcjkalzjuh","tmrfuyrxbp","vhvbdhxehe","qvxhbpphdp","yisfbmynwo","izkdbmgiwp","tfbvzeaovf","efwivrtmgn","mimqapzbsw","rstemorgsk","izsgyehzhe"],
            ["iiyeaigzbe", "rumfiusdti", "aqpyf2ybnf", "ixdgao91gn"],
            ["mowdgakbkd", "xissawltzx", "pwgqbdkprl1", "mfjsadlvhec"],
            ["zceafakvtgm", "febllwpqdk", "lvoldlobjl", "cuqushhaes"],
            ["mowpllkbkd", "xissuoatzx", "pwgdodkprl1", "mfjsadlva1c"]
        ];

        var apples = [
            "http://api.qixinxx.com",
            "http://47.95.32.128",      //备
            "http://47.94.47.91",       //ti
            "http://47.94.43.220",      //ti
            "http://47.94.43.216"       //ti

        ];

        cc.log("size1:" + codess.length);
        cc.log("size2:" + apples.length);

        for (var i = 0; i < apples.length; i++){
            var codes = codess[i];
            var index = mo.gameHelper.findValueForArray(codes, code);
            if (index != null){
                return apples[i];
            }
        }
        return "";
    };

    return that;
};

mo.httpCodes = new HttpCodes();